package com.tom.zojbackendquestionservice.controller.innner;

import com.tom.zojbackendmodel.model.entity.Question;
import com.tom.zojbackendmodel.model.entity.QuestionSubmit;
import com.tom.zojbackendquestionservice.service.QuestionService;
import com.tom.zojbackendquestionservice.service.QuestionSubmitService;
import com.tom.zojbackendserviceclient.service.QuestionFeignClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/inner")
public class QuestionInnerController implements QuestionFeignClient {
    @Resource
    private QuestionService questionService;

    @Resource
    private QuestionSubmitService questionSubmitService;

    @Override
    @GetMapping("/get/id")
    public Question getQuestionById(@RequestParam("questionId") Long questionId) {
        return questionService.getById(questionId);
    }

    @Override
    @GetMapping("/questionsSubmit/get/id")
    public QuestionSubmit getQuestionSubmitById(@RequestParam("submitId") Long submitId) {
        return questionSubmitService.getById(submitId);
    }

    @Override
    @PostMapping("/questionsSubmit/update")
    public boolean updateQuestionSubmitById(@RequestBody QuestionSubmit questionSubmit) {
        return questionSubmitService.updateById(questionSubmit);
    }

    @Override
    @PostMapping("/question/update")
    public boolean updateById(Question updateQuestion) {
        return questionService.updateById(updateQuestion);
    }
}
